#include "CliqueFitnessFunction.h"

#include <set>

double CliqueFitnessFunction::evaluate(const Genotype & genotype, const MatrixGraph & graph)
{
	int bridgeEdges = 0;
	for (std::set<int>::iterator i = genotype.gens.begin(); i != genotype.gens.end(); ++i)
	{
		for (unsigned int j = 0; j < graph.getVSize(); ++j)
		{
			if (graph.areConnectedVerts(*i, j) && genotype.isZero(j) )
			{
				++bridgeEdges;
			}
		}
	}
    //std::cout << "dla genotypu " << genotype << "fitness = " << (genotype.getVSize() * graph.getESize() + bridgeEdges) << std::endl;
	return genotype.getVSize() * graph.getESize() + bridgeEdges;
}

double CliqueFitnessFunction::evaluate(const Genotype & genotype)
{
	return evaluate(genotype, genotype.graph);
}